<?php 
$companyid=$session->read("companyid");
$user=$session->read('User');
$isflag=true;//$action->checkPermissions($user,$companyid);
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2>
			<?php 
			$companyname=$session->read("companyname");
			echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
			?>
		</h2>
		<div class="clear"></div>
	</div>
   <?php 
		if(classregistry::init('User')->personAuthority($user)){
    		echo '<div class="right item_add_btn">';
			echo $html->link(__('添加',true), 'editdepcost');
			echo '</div>';
		}
			//}else{
			//echo '<div class="right enableaction">';
			//echo "<a>添加</a>";
			//echo '</div>';
		//}
	?>
    <?php 
	if($showpage==1)
	{
		if(isset($paging)){ echo $this->renderElement('pagination',$paging);} 
	}
	?>
    <div class="clear"></div>
    <div class="right_sidt_head_screen">
    	<div class="left">
		    <div class="right_side_head_line">
				<ul>
					<li style="width:390px;clear:left">
						<div class="left screen_condition">研发机构数：</div>
						<div class="left screen_counts" ><?php echo $count_institution;?></div>
						<div class="left achievement ">
						<?php 
						if($count_institution>0){
							echo"（";	
							$i=0;					
							foreach ($stitutions as $stitution){
								$i++;											    
						    	if($i>1 ){echo "，";}
							    $id=$stitution["CompInstitution"]["id"];	
								$devlist=$stitution["CompInstitution"]["institution_name"];		
								$remark=$stitution["CompInstitution"]["remark"];	
						    	echo $html->link($devlist,"/companys/showstitution/".$id,array("title"=>$remark));
							}						
							echo"）";
						 }
						?>	
						</div>
						<div class="left screen_condition"><?php echo '&nbsp;'. $html->link("添加",array('action'=>'editstitution'))?></div>
						<div class="clear"></div>
					</li>
					<li style="width:280px;clear:left">
						<?php 
							$AchievementId=$objachieves['CompAchievement']['id'];
							$OutputRemark=$objachieves['CompAchievement']['output_remark'];
							$AwardRemark=$objachieves['CompAchievement']['award_remark'];
						?>
						<div class="left achievement "><?php echo $html->link("产出成果数","/companys/showachieve/".$AchievementId."?status=1",array("title"=>$OutputRemark))?>：</div>
						<div class="left screen_counts" ><?php echo $objachieves['CompAchievement']['output_achievement'];?></div>
						<div class="left achievement">&nbsp;&nbsp;<?php echo $html->link("获奖成果数","/companys/showachieve/".$AchievementId."?status=2",array("title"=>$AwardRemark))?>：</div>
						<div class="left screen_counts" ><?php echo $objachieves['CompAchievement']['award_achievement'];?></div>
						<div class="clear"></div>
					</li>
					<li style="width:130px;clear:left">
						<div class="left screen_condition">总研发费用（￥）：</div>
						<div class="left screen_counts" id="sumprice">0</div>
						<div class="clear"></div>
					</li>
				</ul>
			</div>
		</div>
		<div class="right display_by_year_btn"><?php echo $html->link('按年度显示',"/companys/timedepcosts/",null,null); ?></div>
		<div class="clear"></div>
	</div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="items_list">
        	<table>
            	<tr>
                	<th><?php echo '时间'; ?></th>
                    <th><?php echo '总额（￥）' ;?></th>
                    <th>占总营额比重（%）</th>
                    <th>研究与实验（￥）</th>
                    <th>新产品费用（￥）</th>
                    <th>政府拨款（￥）</th>
                    <th>企业自筹费用（￥）</th>
                    <th><?php __("Action")?></th>
                </tr>
                <?php 
                $sumprice=0;
				foreach($costs as $cost){
					$id=$cost["DevelopmentCost"]["id"];
					echo "<tr class='per_list'>";
					echo "<td>".$html->link(date("Y-m-d",strtotime($cost["DevelopmentCost"]["c_time"])),"/companys/showdepcost/".$id)."</td>";
					$dcost=$cost['DevelopmentCost']['cost'];
					$sumprice+=$dcost;
					echo "<td>".$dcost."</td>";
					echo "<td>".$cost['DevelopmentCost']['cost_percent']."</td>";
					echo "<td>".$cost['DevelopmentCost']['research_exp']."</td>";
					echo "<td>".$cost['DevelopmentCost']['new_product']."</td>";
					echo "<td>".$cost['DevelopmentCost']['govern_funding']."</td>";
					echo "<td>".$cost['DevelopmentCost']['raised_enterprise']."</td>";
					echo "<td>";
					if(classregistry::init('User')->personAuthority($user)&&classregistry::init('Company')->personAuthority($cost)){
						echo $html->link(__("Edit",true),"/companys/editdepcost/".$id,null,null);
						echo $html->link(__("Delete",true),"/companys/deldepcost/".$id,array("onclick"=>"return doaction(this)"));
					}else{
						echo "<span class='enableaction'>编辑</span>";
						echo "<span class='enableaction'>删除</span>";
					}
					echo "</td>";
					echo "</tr>";
				}?>
            </table>
            <?php if($sumprice){?>
            	<script>$("#sumprice").html("<?php echo $sumprice?>");</script>
            <?php }?>
		</div>
	</div>
</div>
<?php echo $this->element('actionconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>